//
//  ButtonHandle.m
//  go
//
//  Created by 袁飞 on 12-7-19.
//
//

#import "ButtonHandle.h"
#import "cocos2d.h"
#import "FSwitch.h"

@implementation ButtonHandle
static ButtonHandle *_sharedButtonHandle = nil;

+ (ButtonHandle *)sharedButtonHandle
{
	if (!_sharedButtonHandle) {
    _sharedButtonHandle = [[ButtonHandle alloc] init];
	}
	return _sharedButtonHandle;
}

-(id)init{
  [super init];
  objs_ = [NSMutableArray array];
  [objs_ retain];
  return self;
}

-(void)setLayer:(test*)l{
  l_ = l;
}

-(void)addObject:(FObject*)obj{
  [objs_ addObject:obj];
}

-(void)onHandle:(NSString*)name{
  //NSLog(@"#####%@", name);
  if([name compare:@"showwnd"] == NSOrderedSame){
    for (FObject *o in objs_) {
      [l_ removeChild:o cleanup:false];
    }
    /*CCLayer* l = [[[CCLayer alloc] init] autorelease];
    CCSprite *sp = [CCSprite spriteWithSpriteFrameName:@"golden_dialog_1.png"];
    [l addChild:sp];
    [l setPosition:ccp(240, 160)];
    [l_ addChild:l];
    return;*/
  }else{
    [l_ change:name];
  }
}

-(void)onSwithChange:(FControl*)ctrl{
  FSwitch *sw = ctrl;
  [l_ showList:![sw ison]];
}

@end
